from selenium import webdriver
from selenium.webdriver.common.by import By # 导入By模块
import time

d = webdriver.Chrome()
d.get('https://www.baidu.com')
time.sleep(2)

# 定位到 hao123
# <a href="https://www.hao123.com?src=from_pc" target="_blank" class="mnav c-font-normal c-color-t">hao123</a>
# a 标签是文本链接标签
# href属性 对应的值就是跳转的网址
# a = d.find_element(By.LINK_TEXT, 'hao123') # 定位到hao123这个文本链接
# a.click()
# time.sleep(3)

# 局部的文本链接定位
b = d.find_element(By.PARTIAL_LINK_TEXT, 'o123')
b.click()
time.sleep(5)
d.quit()
